package core;

/**
 * An Attribute that has a String value.
 */
public class TextAttribute extends Attribute<TextAttribute.StringValue>
{
	public TextAttribute() {
		this(null);
	}

	public TextAttribute(String name) {
		super(name);
	}

	/**
	 * Create a new Attribute that maps the given name to the given value
	 * @param name the name of the Attribute
	 * @param value the value it stores
	 */
	public TextAttribute(String name, String value) {
		super(name, value == null ? null : new StringValue(value));
	}

	public StringValue parseString(String stringValue) {
		return new StringValue(stringValue);
	}

	// you might think this could be genericized, but you'd be wrong
	public static class StringValue {
		public StringValue() {this(null);}
		public StringValue(String value) {setValue(value);}
		public String getValue() {return value;}
		public void setValue(String value) {this.value = value;}
		public String toString() {return value;}
		private String value;
	}
}